home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Graphics Programming (2nd Edition)
/
Visual Basic Graphics Programming 2nd Edition.iso
/
OldSrc
/
CH3
/
SRC
/
GETENTRY.FRM
< prev
next >
Wrap
Text File
|
1996-05-01
|
5KB
|
177 lines
VERSION 4.00
Begin VB.Form GetEntryForm
Caption = "GetEntry"
ClientHeight = 3495
ClientLeft = 1500
ClientTop = 1260
ClientWidth = 5910
Height = 4185
Left = 1440
LinkTopic = "Form1"
ScaleHeight = 3495
ScaleWidth = 5910
Top = 630
Width = 6030
Begin VB.TextBox EntryText
BeginProperty Font
name = "Courier New"
charset = 1
weight = 400
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 3495
Left = 3480
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 1
Top = 0
Width = 2415
End
Begin VB.PictureBox Pict
AutoRedraw = -1 'True
Height = 3495
Left = 0
ScaleHeight = 229
ScaleMode = 3 'Pixel
ScaleWidth = 221
TabIndex = 0
Top = 0
Width = 3375
End
Begin MSComDlg.CommonDialog FileDialog
Left = 3240
Top = 3120
_version = 65536
_extentx = 847
_extenty = 847
_stockprops = 0
cancelerror = -1 'True
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileLoad
Caption = "&Load..."
Shortcut = ^L
End
Begin VB.Menu mnuFileSep
Caption = "-"
End
Begin VB.Menu mnuFileExit
Caption = "E&xit"
End
End
End
Attribute VB_Name = "GetEntryForm"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
' ***********************************************
' Display a list of the colors in the logical
' palette.
' ***********************************************
Sub ShowEntries()
Dim num_entries As Integer
Dim palentry(0 To 255) As PALETTEENTRY
Dim i As Integer
Dim txt As String
Dim istr As String
Dim rstr As String
Dim gstr As String
Dim bstr As String
If Pict.Picture = 0 Then
EntryText.Text = "No picture loaded."
Exit Sub
ElseIf Pict.Picture.hPal = 0 Then
EntryText.Text = "Default palette."
Exit Sub
End If
num_entries = GetPaletteEntries(Pict.Picture.hPal, 0, 256, palentry(0))
txt = " # Red Green Blue" & vbCrLf
For i = 0 To num_entries - 1
istr = Format$(i)
rstr = Format$(palentry(i).peRed)
gstr = Format$(palentry(i).peGreen)
bstr = Format$(palentry(i).peBlue)
txt = txt & _
Space$(3 - Len(istr)) & istr & ":" & _
Space$(4 - Len(rstr)) & rstr & _
Space$(6 - Len(gstr)) & gstr & _
Space$(5 - Len(bstr)) & bstr & vbCrLf
Next i
EntryText.Text = txt
End Sub
Private Sub Form_Load()
' Make sure the screen supports palettes.
If Not GetDeviceCaps(hdc, RASTERCAPS) And RC_PALETTE Then
Beep
MsgBox "This monitor does not support palettes.", _
vbCritical
End
End If
ShowEntries
End Sub
Private Sub Form_Resize()
Dim wid As Single
EntryText.Move ScaleWidth - EntryText.Width, _
0, EntryText.Width, ScaleHeight
wid = EntryText.Left - 20
If wid < 100 Then wid = 100
Pict.Move 0, 0, wid, ScaleHeight
End Sub
Private Sub mnuFileExit_Click()
Unload Me
End Sub
Private Sub mnuFileLoad_Click()
Dim fname As String
' Allow the user to pick a file.
On Error Resume Next
FileDialog.filename = "*.BMP;*.ICO;*.RLE;*.WMF;*.DIB"
FileDialog.Flags = cdlOFNFileMustExist + cdlOFNHideReadOnly
FileDialog.ShowOpen
If Err.Number = cdlCancel Then
Exit Sub
ElseIf Err.Number <> 0 Then
Beep
MsgBox "Error selecting file.", , vbExclamation
Exit Sub
End If
On Error GoTo 0
MousePointer = vbHourglass
DoEvents
fname = Trim$(FileDialog.filename)
FileDialog.InitDir = Left$(fname, Len(fname) _
- Len(FileDialog.FileTitle) - 1)
' Load the picture.
Pict.Picture = LoadPicture(fname)
Caption = "GetEntry [" & fname & "]"
' Update the list of colors.
ShowEntries
MousePointer = vbDefault
End Sub